package com.gitee.dengmin.tenant.exception;

import com.gitee.dengmin.tenant.response.ApiResult;
import lombok.extern.slf4j.Slf4j;
import org.springframework.core.annotation.Order;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

@Slf4j
@Order(1)
@ControllerAdvice
@ResponseBody
public class GlobalException {

    @ExceptionHandler(RuntimeException.class)
    public ApiResult<Object> handlerRuntimeException(RuntimeException e){
        log.error(e.getMessage(), e);
        return ApiResult.error(e.getMessage());
    }

}
